package string.nowcoder.easy;

import java.util.Scanner;

/**
 * @author Stark
 * @description 两种排序方法
 * 题目链接:https://www.nowcoder.com/practice/839f681bf36c486fbcc5fcb977ffe432?
 * tpId=85&&tqId=29844&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking
 * @date 2022/4/25 23:51
 **/
public class TwoSortFun {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            String[] strings = new String[n];
            for(int i = 0; i < n ; i++){
                strings[i] = in.next();
            }
            boolean flagGraph = true;
            boolean flagLength = true;
            for(int i = 0 ; i < n - 1; i++){
                if(strings[i].compareTo(strings[i + 1]) > 0)
                    flagGraph = false;
                if(strings[i].length() > strings[i + 1].length())
                    flagLength = false;
            }
            if(flagGraph){
                if(flagLength){
                    System.out.println("both");
                }else{
                    System.out.println("lexicographically");
                }
            }else{
                if(flagLength){
                    System.out.println("lengths");
                }else{
                    System.out.println("none");
                }
            }
        }
    }
}
